﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.gradeinfo
{
    public partial class ModifyAZ : lcs.Web.Admin.BasePage
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    int gdid = (Convert.ToInt32(Request.Params["id"]));
                    ShowInfo(gdid);
                }
            }
        }

        private void ShowInfo(int gdid)
        {
            lcs.BLL.gradeinfo bll = new lcs.BLL.gradeinfo();
            lcs.Model.gradeinfo model = bll.GetModel(gdid);
            this.lblgdid.Text = model.gdid.ToString();
            this.txtazs.Text = model.azs.ToString();
            this.txtaze.Text = model.aze.ToString();
            this.txtazsum.Text = model.azsum.ToString();

        }

        public void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            int gdid = int.Parse(this.lblgdid.Text);
            //int monthsupplyid=int.Parse(this.txtmonthsupplyid.Text);
            decimal azs = decimal.Parse(this.txtazs.Text);
            decimal aze = decimal.Parse(this.txtaze.Text);
            decimal azsum = decimal.Parse(this.txtazsum.Text);
            lcs.Model.gradeinfo model = new lcs.Model.gradeinfo();
            model.gdid = gdid;

            model.azs = azs;
            model.aze = aze;
            model.azsum = azsum;
            decimal jg = 0;
            //=IF(U7/T7>=0.05,0,10-U7/T7*200)
            jg = aze / azs;
            if (jg < 0.05M)
            {
                jg = 10 - jg * 200;
            }
            else
                jg = 0;

            model.azmark = jg;                      
            model.pfdatetime = DateTime.Now;
            lcs.BLL.gradeinfo bll = new lcs.BLL.gradeinfo();
            bll.UpdateAZ(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "mylist.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("mylist.aspx");
        }
    }
}
